<template>
	<div>
		<div class="Abox" v-loading="loading">
			<div class="content">
				<Info
					ref="Info"
					v-model="infoData"
					v-bind="querys"
					state="readonly"></Info>
				<Contract
					ref="Contract"
					v-model="infoData"
					v-bind="querys"
					:showHistory="false"
					state="readonly"></Contract>
				<Footer
					ref="Footer"
					v-model="infoData"
					v-bind="querys"
					state="readonly"></Footer>
				<!-- <el-button -->
				<!-- class="orderChangeHistory" -->
				<!-- type="primary" -->
				<!-- @click="toOrderChangeHistory"> -->
				<!-- 查看变更历史记录 -->
				<!-- </el-button> -->
			</div>
			<div>
				<A-FlowRecord :id="processId"></A-FlowRecord>
			</div>
		</div>
		<div class="handle">
			<el-button @click="back">返回</el-button>
		</div>
	</div>
</template>

<script>
	import * as apis from '@/api/order/mainOrder/contractChange/api.js';
	import Info from '../chunk/info/index.vue';
	import Contract from '../chunk/contract/index.vue';
	import Footer from '../chunk/footer/index.vue';
	export default {
		name: 'ContractChangePreview',
		props: {
			state: {
				required: false,
			},
		},
		components: { Info, Contract, Footer },
		data() {
			return {
				infoData: {},
				querys: {},
				loading: false,
			};
		},

		computed: {
			processId() {
				return this.infoData.processId;
			},
		},
		created() {
			this.querys = this.$route.query ?? {};
			this.getOrderChangeInfo();
		},
		mounted() {},
		methods: {
			getOrderChangeInfo() {
				if (this.Empty(this.querys.orderChangeId)) {
					this.$message.error('缺少参数 订单改变id');
					return;
				}
				this.loading = true;
				apis.OrderChangeInfo(this.querys.orderChangeId)
					.then(res => {
						if (res.code == 200) {
							this.infoData = res.data ?? {};
							this._onload();
						}
					})
					.finally(() => {
						this.loading = false;
					});
			},
			toOrderChangeHistory() {
				this._toPage({
					name: 'OrderChangeHistory',
					query: {
						orderId: this.querys.orderId,
					},
				});
			},
			back() {
				this._closeCurrentPage();
				if (this.notEmpty(this.$route.query.from)) {
					this._toPage({
						name: this.$route.query.from,
						query: this.$route.query,
					});
				}
			},
		},
	};
</script>

<style lang="scss" scoped>
	.orderChangeHistory {
		position: fixed;
		bottom: calc(100vh - 150px);
		right: 40px;
		cursor: pointer;
		transition: all 0.3s;
	}
	.handle {
		height: 60px;
		display: flex;
		justify-content: flex-end;
		align-items: center;
		background-color: #fff;
		margin: 20px;
		padding: 0 20px;
		border-radius: 8px;
		box-sizing: border-box;
	}
	.Abox {
		display: flex;
		.content {
			flex: 1;
			min-width: 0;
		}
	}
</style>
